package cn.gameback.supervisionservices.util;

import com.google.gson.Gson;

public class Result<T> {
    private int code;
    private String message;
    private T data;


    public Result(T data) {
        this.code = 200; // 假设200表示成功
        this.data = data;
    }

    public Result(int code, String message) {
        this.code = code;
        this.message = message;
    }

    // 将当前对象转换为JSON字符串
    public String toJson() {
        Gson gson = new Gson();
        return gson.toJson(this);
    }

    // getters and setters
    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
